package com.yq.controller;

import com.yq.domain.SysUser;
import com.yq.service.SysMenuService;
import com.yq.service.SysUserService;
import com.yq.service.impl.SysUserServiceImpl;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("sys/user")
@Api("管理员接口")
public class SysUserController {

    @Autowired
    private SysUserServiceImpl sysUserService;

    @GetMapping("info")
    public ResponseEntity<SysUser> info(){
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        String userId = authentication.getPrincipal().toString();
        SysUser sysUser = sysUserService.getById(Long.valueOf(userId));
        return ResponseEntity.ok(sysUser);
    }

}
